<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('断裂损伤信息列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>零件名：</label>
                                <select name="partName" th:with="type=${@dict.getType('sys_part')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>材料种类：</label>
                                <select name="materialType" th:with="type=${@dict.getType('sys_material')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>材料牌号：</label>
                                <input type="text" name="materialGrade"/>
                            </li>
                            <li>
                                <label>试样状态：</label>
                                <select name="sampleStatus" th:with="type=${@dict.getType('sys_material')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">

                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="knowledge:damage:export">
                    <i class="fa fa-download"></i> 下载
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var partNameDatas = [[${@dict.getType('sys_part')}]];
        var materialTypeDatas = [[${@dict.getType('sys_material')}]];
        var sampleStatusDatas = [[${@dict.getType('sys_material')}]];
        var prefix = ctx + "knowledge/damage";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                detailUrl: prefix + "/detail/{id}",
                exportUrl: prefix + "/export",
                modalName: "断裂损伤信息",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'id',
                    title: '',
                    visible: false
                },
                {
                    field: 'partName',
                    title: '零件名',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(partNameDatas, value);
                    }
                },
                {
                    field: 'materialType',
                    title: '材料种类',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(materialTypeDatas, value);
                    }
                },
                {
                    field: 'materialGrade',
                    title: '材料牌号'
                },
                {
                    field: 'sampleStatus',
                    title: '试样状态',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(sampleStatusDatas, value);
                    }
                },
                {
                    field: 'damageDescription',
                    title: '断裂损伤信息'
                },
                {
                    field: 'attachmentPath',
                    title: '附件',
                     formatter: function(value, row, index) {
                         return "<img src='" + row.attachmentPath + "' class=\"attachment-img\">"
                     }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="$.operate.detail(' + row.id + ')"><i class="fa fa-edit"></i>浏览</a> ');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
    </script>
</body>
</html>